{% for comment in obj.commentList %}
<div class="doc-example container-fluid" id="comment_div_{{comment.id}}">
  <ul class="am-comments-list am-comments-list-flip">
    <li class="am-comment am-comment-success">
    <a href="/account/user/{{comment.reviewer.id}}/">
      <img src="{{comment.reviewer.portraitUri}}" alt="" class="am-comment-avatar" width="50" height="50">

    </a>
    <div class="am-comment-main">
      <header class="am-comment-hd">
        <div class="am-comment-meta">
          <a href="/account/user/{{comment.reviewer.id}}/" class="am-comment-author">
            {{comment.reviewer.nickname}}
          </a>
          评论于 {{comment.createTime|date:"Y/m/d"}}
        </div>
      </header>

      <div class="am-comment-bd">
        <p>
          {{comment.content}}
        </p>
        <br>
        <!-- reply list -->
        {% for reply in comment.allreply.all %}
        <div class="alert alert-success" role="alert" id="reply_contentdiv_{{reply.id}}">
          <p>
            &nbsp&nbsp&nbsp
            <a href="/account/user/{{reply.firstPer.id}}/">
              {{reply.firstPer.nickname}}
            </a>
            回复 {{reply.secondPer.nickname}} :{{reply.content}}
          </p>
          <p align="right">
            <a onClick="replyToReviewer({{comment.id}},{{reply.firstPer.id}},'{{reply.firstPer.nickname}}')" href="javascript:void(0)">
              <i class="am-icon-mail-reply">
              </i>
              回复
            </a>
          </p>

        </div>
        {% endfor %}
        <!-- reply list end-->
        <!--
          <p> &nbsp&nbsp&nbsp <a href=""> 更多&raquo; </a> </p>
        -->

        <p align="left">
          <a onClick="replyToReviewer({{comment.id}},{{comment.reviewer.id}},'{{comment.reviewer.nickname}}')" href="javascript:void(0)">
            <i class="am-icon-mail-reply">
            </i>
            回复({{comment.allreply.all.count}})
          </a>

          &nbsp&nbsp
          <a href="">
            <i class="am-icon-flag">
            </i>
            举报
          </a>
          &nbsp&nbsp
        </p>
        <form id="replyform_{{comment.id}}" name="replyform"  method="POST" >
          <div id="reply_div_{{comment.id}}" style="display:none;">
            回复 <span id="receiver_nickname_{{comment.id}}"></span>:
            <input 
                 class="form-control"
                id="reply_input_{{comment.id}}"
                name="reply_input_{{comment.id}}">

            <button class="btn btn-warning" onclick="submitReply({{comment.id}})">
              发送
            </button>
            <input 
                id="receiverid_input_{{comment.id}}"
                name="receiverid_input_{{comment.id}}"
                type="hidden">

          </div>
          {% csrf_token %}
        </form>


      </div>
    </div>
  </ul>
</div>


{% endfor %}
<script type="text/javascript">
  receiver=0
  /**
  *
  *@param index:评论id值
  *@param receiverId:回复的接受者
  */
  function replyToReviewer(index,receiverId,nickname){
    $("#reply_div_"+index).css("display","block");
    $("#receiver_nickname_"+index).html(nickname)
    $("#reply_input_"+index).focus();
    
    $("#receiverid_input"+index).html(receiverId);
    receiver=0;
    receiver=receiverId;
  }

  function submitReply(comment_id){
    actionUrl="./comment/"+comment_id+"/receiver/"+receiver+"/reply/addition/"
    
    $("#replyform_"+comment_id).attr("action",actionUrl).submit();
  }
</script>
